package biz.innovasoft.nodb.transaction;

import java.util.Date;

import org.prevayler.Transaction;

import biz.innovasoft.nodb.impl.GenericRepository;

public class ReindexTransaction implements Transaction {

	private static final long serialVersionUID = 1L;
	
	private Object data;
	
	public ReindexTransaction () {
	}
	
	public ReindexTransaction (Object data) {
		this.data = data;
	}
	
	@Override
	public void executeOn(Object prevalentSystem, Date time) {
		GenericRepository repository = (GenericRepository)prevalentSystem;
		if ( data == null ) {
			repository.reindex();
		} else {
			repository.reindex((Class<?>)data);
		}
		
	}

}
